package com.gouldzd.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.gouldzd.constant.MessageConstant;
import com.gouldzd.entity.PageResult;
import com.gouldzd.entity.QueryPageBean;
import com.gouldzd.entity.Result;
import com.gouldzd.pojo.Setmeal;
import com.gouldzd.service.SetMealService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 * @Author zhangdan
 * @Description //TODO 体检套餐管理
 * @Date 9:56 2020/4/28
 * @Param
 * @return
 **/
@RestController
@RequestMapping("/setmeal")
public class SetMealController {

    @Reference
    private SetMealService setMealService;

    //新增套餐
    @RequestMapping("/add")
    public Result add(@RequestBody Setmeal setmeal, Integer[] checkgroupIds){
        try {
            setMealService.add(setmeal,checkgroupIds);
        } catch (Exception e) {
            e.printStackTrace();
            //服务调用失败,进入catch
            return new Result(false, MessageConstant.ADD_SETMEAL_FAIL);
        }

        return new Result(true, MessageConstant.ADD_SETMEAL_SUCCESS);
    }

    //套餐分页查询
    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        PageResult pageResult= setMealService.pageQuery(queryPageBean);
        return pageResult;
    }

}
